package login

class LoginController {

    def index() {
        render(view:"LoginView");
    }
    
    def doLogin() {
        //findWhere method is quick look up for user with given parameters
        def valid_user = User.findWhere(email:params['email'], password:params['password'])
        //If such a user is found, the login is succesful
        if (valid_user) {
            def map = [user:params['email']]
            render(view:"SuccesView", model:map)
        }
        //If not, back to loginview
        else {
            render(view:"LoginView")
        }
    }
}
